import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.print.*;

 /*
  * Name: Drawing.java
  * Function: Creates a Panel to display a DrawPanel object and a Print button.
  *
  */
public class Drawing extends JFrame implements ActionListener {

 /*
  * Name: Drawing(Calculation c)
  * Description: Constructs a Panel that displays a DrawPanel object and creates a Print button.
  *              Passes Calculation object to DrawPanel constructor.
  * Param: Calculation c
  * Returns: Nothing
  */
  public Drawing(Calculation c) {
    super("Sundial");
    Container content = getContentPane();
    JButton printButton = new JButton("Print");
    printButton.addActionListener(this);
    JPanel buttonPanel = new JPanel();
    buttonPanel.setBackground(Color.white);
    buttonPanel.add(printButton);
    content.add(buttonPanel, BorderLayout.SOUTH);
    DrawPanel drawingPanel = new DrawPanel(c);
    content.add(drawingPanel, BorderLayout.CENTER);
    pack();
    setVisible(true);
  }
  
   /*
  * Name: actionPerformed(ActionEvent event)
  * Description: Preforms a printing action when button is pressed.
  * Param: ActionEvent event
  * Returns: Nothing
  */
  
  public void actionPerformed(ActionEvent event) {
	    Printing.printComponent(this);
	  }
}